package com.zzw.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 阿里云OSS客户端配置类
 * @author 赵志伟
 * @version 1.0
 */
@SuppressWarnings({"all"})
@Configuration
public class OssClientConfig {
    @Value("${oss.endpoint}")
    private String endpoint;

    @Value("${oss.accessKeyId}")
    private String accessKeyId;

    @Value("${oss.accessKeySecret}")
    private String accessKeySecret;

    @Value("${oss.bucketName}")
    private String bucketName;

    /**
     * 创建阿里云OSS客户端Bean
     * @return OSS客户端实例
     */
    @Bean
    public OSS ossClient() {
        OSSClientBuilder ossClientBuilder = new OSSClientBuilder();
        return ossClientBuilder.build(endpoint, accessKeyId, accessKeySecret);
    }
}
